package com.donn.securitycontrolplatform.usertag.controller;

import com.donn.securitycontrolplatform.common.Result;
import com.donn.securitycontrolplatform.usertag.entity.UserTag;
import com.donn.securitycontrolplatform.usertag.service.IUserTagService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 用户和标签关联表 前端控制器
 * </p>
 *
 * @author zhenglixiang
 * @since 2022-06-13
 */
@RestController
@RequestMapping("/scp/api/user/tag")
@Tag(name = "user-tag-controller", description = "用户绑定标签接口")
public class UserTagController {

    @Autowired
    IUserTagService service;

    @ApiOperation(value = "新增用户标签关联")
    @PostMapping("/add")
    @ResponseBody
    public Result add(@RequestBody @ApiParam(value = "用户绑定标签对象") UserTag userTag) {
        return service.insertUserTag(userTag);
    }

    @ApiOperation(value = "修改用户标签关联")
    @PutMapping("/update")
    @ResponseBody
    public Result update(@RequestBody @ApiParam(value = "用户绑定标签对象") UserTag userTag) {
        return service.updateUserTag(userTag);
    }

    @ApiOperation(value = "删除用户标签关联")
    @DeleteMapping("/delete")
    @ResponseBody
    public Result delete(@RequestParam @ApiParam(value = "用户id",required = true) String userId) {
        return service.deleteUserTag(userId);
    }

    @ApiOperation(value = "用户标签关联信息")
    @GetMapping("/get")
    @ResponseBody
    public Result get(@RequestParam @ApiParam(value = "用户id",required = true) String userId) {
        return service.geUserTagById(userId);
    }

    @ApiOperation(value = "查询列表")
    @PostMapping("/list")
    @ResponseBody
    public Result list(@RequestBody @ApiParam(value = "用户id集合",required = true) List<String> userIds) {
        return service.selectUserTagByIds(userIds);
    }
}
